﻿<UserControl x:Class="$safeprojectname$.CustomerView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:mvvm="clr-namespace:SimpleMvvmToolkit;assembly=SimpleMvvmToolkit-WindowsPhone-v8.0"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">

    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}"
          DataContext="{Binding Source={StaticResource Locator}, Path=CustomerViewModel}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <TextBlock Text="Customer Id:" Grid.Row="0" VerticalAlignment="Center" />
        <TextBox Grid.Row="0" Grid.Column="1" Height="72" 
                 HorizontalAlignment="Left" VerticalAlignment="Center" Width="460"
                 Text="{Binding Path=Model.CustomerId}" />
        <TextBlock Text="Customer Name:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" />
        <TextBox Grid.Row="1" Grid.Column="1" Height="72" 
                 HorizontalAlignment="Left" VerticalAlignment="Center" Width="460"
                 Text="{Binding Path=Model.CustomerName}" />
        <TextBlock Text="Customer City:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" />
        <TextBox Grid.Row="2" Grid.Column="1" Height="72" 
                 HorizontalAlignment="Left" VerticalAlignment="Center" Width="460"
                 Text="{Binding Path=Model.City}" />
        <Button Content="New Customer" Grid.Column="1" Grid.Row="3" Height="72" Margin="12,24,65,24">
            <!-- STEP 3: Use EventToCommand to bind Click event to view-model command -->
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <mvvm:EventToCommand
                        Command="{Binding NewCustomerCommand}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>
    </Grid>
</UserControl>